<template>
	<gui-page>
		<!-- 页面主体 -->
		<template v-slot:gBody>
			<view>
				<form @submit="submit">
					<view 
					class="gui-bg-white gui-dark-bg-level-3 ">
						<view class="tipbox">
							<view class="t">1: 支付宝/微信账户姓名必须与实名认证名保持一致，否则无法提现</view>
							<view class="t">2: 每日支付宝/微信个人账户转入上线是5万元，企业账户转入上线是10万元，如超出额度请联系客服。</view>
							<view class="t">3: 目前使用支付宝/微信账户进行提现，但若后期平台策略发生变更将更具后续进行调整和另行通知，谢谢。</view>
						</view>
					</view>
					<view style="height:60rpx;"></view>
				</form>
			</view>
		</template>
	</gui-page>
</template>
<script>
import graceChecker from "@/Grace6/js/checker.js";
export default {
	data() {
		return {
			formData : {
				name1 : "GraceUI",
				name2 : "888888",
				name3 : "888888",
				name4 : "888888@qq.com",
				name5 : '请选择性别',
				name7 : '123456',
				name8 : ''
			},
			gender : ['请选择性别', '男', '女'],
			genderIndex : 0
		}
	},
	methods: {
		submit : function(e){
			//定义表单规则
			var rule = [
				{name:"name1", checkType : "string", checkRule:"1,10", errorMsg:"**应为1-10个字符"},
				{name:"name2", checkType : "string", checkRule:"6,", errorMsg:"密码至少6个字符"},
				{name:"name3", checkType : "samewith", checkRule:"name2", errorMsg:"两次密码输入不一致"},
				{name:"name4", checkType : "email", checkRule:"", errorMsg:"邮箱格式错误"},
				{name:"name5", checkType : "notsame", checkRule:"请选择性别", errorMsg:"请选择性别"},
				// 正则表达式验证演示 : 例如检查必须是有效数字
				{name:"name7", checkType : "reg", checkRule:"^(-?\\d+)$", errorMsg:"必须是有效数字"},
				{name:"name8", checkType : "idCard", checkRule:"", errorMsg:"身份证号码错误"}
			];
			//进行表单验证 e.detail.value 内存放着表单数据
			var formData   = e.detail.value;
			formData.name5 = this.formData.name5;
			console.log(formData);
			var checkRes = graceChecker.check(formData, rule);
			if(checkRes){
				// 当验证 js 不适用某个检查时，使用自定义函数进行检查
				if(formData.name6.length < 1){
					uni.showToast({title:"请选择爱好!", icon:"none"});
					// return 会终止函数继续运行哦
					return false;
				}
				uni.showToast({title:"验证通过!", icon:"none"});
			}else{
				uni.showToast({ title: graceChecker.error, icon: "none" });
			}
			
		},
		pickerChange : function (e) {
			this.genderIndex    = e.detail.value;
			this.formData.name5 = this.gender[this.genderIndex];
		}
	}
}
</script>
<style scoped lang="scss">
	.tipbox{
		background:#f8f8f8;padding:40rpx;font-size:26rpx;
		line-height: 42rpx;
	}
	.tipbox .t{margin-bottom: 10rpx;}
</style>